package alfred.mdp.messages.client;

import alfred.mdp.Majordomo;
import alfred.mdp.messages.ProtocolMessage;
import org.zeromq.ZFrame;
import org.zeromq.ZMsg;

/**
 * Reply<br>
 * Frame 0: Empty (zero bytes, invisible to REQ application)<br>
 * Frame 1: "MDPC01" (six bytes, representing MDP/Client v0.1)<br>
 * Frame 2: Service name (printable string)<br>
 * Frames 3+: Reply body (opaque binary)<br>
 */
public class Reply extends ProtocolMessage {

    public Reply(ZFrame clientId, String service, ZMsg message) {
        super(
                clientId,
                Majordomo.EMPTY,
                Majordomo.PROTOCOL_CLIENT_V,
                asZFrame(service)
        );
        getZMsg().addAll(message);
    }

    public Reply(ZMsg received) {
        super(received);
    }

    public ZMsg getBody() {
        return getSubMsg(3);
    }
}
